import { ref, unref } from 'vue';
import { driver } from "driver.js";
import "driver.js/dist/driver.css";

export function useDriver(steps, options = {}){
  const driverObj = driver({
    ...options,
    steps: unref(steps),
    onDestroyStarted: () => {
      options.onDestroyStarted(driverObj);
    }
  });

  const startDriver = () => {
    driverObj.drive();
  }

  const destroyDriver = () => {
    driverObj.destroy();
  }

  return {
    startDriver,
    destroyDriver
  }
}